//
//  ZYImageViewClick.m
//  Matchmaker v4
//
//  Created by ZhangYuan on 15/4/30.
//  Copyright (c) 2015年 lordZhou. All rights reserved.
//

#import "XMImageViewClick.h"

@implementation XMImageViewClick
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self initSubviews];
        [self addGesture];
        self.userInteractionEnabled=YES;
    }
    return self;
}

- (void)initSubviews
{
    _imageView = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-40, 60/2-30/2, 20, 30)];
    _imageView.contentMode = UIViewContentModeScaleAspectFit;
    _imageView.userInteractionEnabled = YES;
    [self addSubview:_imageView];
}

- (void)addGesture
{
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didItemView:)];
    [self addGestureRecognizer:tap];
    
}

#pragma mark --- click----
- (void)didItemView:(UITapGestureRecognizer *)tap
{
    if ([self.myDelegate respondsToSelector:@selector(clickImageAction:)]) {
        [self.myDelegate clickImageAction:self];
    }else if ([self.myDelegate respondsToSelector:@selector(clickImageAction:andFlag:)]){
        [self.myDelegate clickImageAction:self andFlag:_flag ];
    }
    else if ([self.myDelegate respondsToSelector:@selector(clickHeadImageURLAction:)]){
        [self.myDelegate clickHeadImageURLAction:_imageURL];
    }else if ([self.myDelegate respondsToSelector:@selector(clickImageAction:andMemberID:)]){
        [self.myDelegate clickImageAction:self andMemberID:_memberID ];
    }
}

@end
